import React, { Component } from 'react'
import './city.less'
import ComponentHead from '../../components/componenthead/componenthead'
import Hotcity from './hotcity/hotcity'
import {connect} from 'react-redux'
class City extends Component{
     render(){
         console.log(this.props)
         return(
             <div className='city'>
                 {/* 头部信息 */}
                 <ComponentHead title='城市选择' history={this.props.history}/>
                 {/* 当前城市 */}
                 <div className='curcity'>
                     当前城市：{this.props.city}
                 </div>
                 {/* 热门城市 */}
                 <Hotcity setcity={this.props.setcity}/>
             </div>
         )
     }
 }

 function mapStateToProps(state){
     return{
         city:state.city
     }
 }
 function mapDispatchToProps(dispatch){
     return{
         setcity:(cs)=>{
            dispatch({type:'SETCITY',playload:cs})
         }
     }
 }
 export default connect(mapStateToProps,mapDispatchToProps)(City)